//== SAGITTARIUS ============================================================================

//== BEGINNING OF CODE ===============================================================

#ifndef __SAGUTTARUIS__PAGEHEAP__H_
#define __SAGUTTARUIS__PAGEHEAP__H_

//== INCLUDES ========================================================================

#include "sagittarius/core/SagittariusCore.h"
#include "sagittarius/mem/sizeclass.h"
#include "sagittarius/mem/sysalloc.h"
#include "sagittarius/mem/span.h"
#include "sagittarius/patterns/hashtable_th.h"

#ifdef __cplusplus
extern "C" {
#endif

//this is enough, as they grow geometrically
#define SG_MAX_SPAN 2048

typedef struct {
    unsigned int gf;
    sg_span spans[SG_MAX_SPAN];
} sg_pageheap; //per size-class

typedef struct {
    sg_pageheap heaps[SG_NUM_SIZECLASSES];
    SG_DEF_MULTISEMA(sema);
} sg_smoheap;

typedef hashtable64 spanhash_t;



int init_smo_heap(sg_smoheap* smoheap, spanhash_t** sh);
int destroy_smo_heap(sg_smoheap* smoheap);

//small objects
void* smo_heapalloc(sg_smoheap* smoheap, sg_sclass b);

#ifdef __cplusplus
}//extern "C"
#endif

#endif
